home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue50 / COMCorn / SteveASO_TLB.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1999-09-03  |  9.6 KB  |  269 lines

  1. unit SteveASO_TLB;
  2.  
  3. // ************************************************************************ //
  4. // WARNING                                                                    
  5. // -------                                                                    
  6. // The types declared in this file were generated from data read from a       
  7. // Type Library. If this type library is explicitly or indirectly (via        
  8. // another type library referring to this type library) re-imported, or the   
  9. // 'Refresh' command of the Type Library Editor activated while editing the   
  10. // Type Library, the contents of this file will be regenerated and all        
  11. // manual modifications will be lost.                                         
  12. // ************************************************************************ //
  13.  
  14. // PASTLWTR : $Revision:   1.88  $
  15. // File generated on 9/3/99 4:07:33 AM from Type Library described below.
  16.  
  17. // *************************************************************************//
  18. // NOTE:                                                                      
  19. // Items guarded by $IFDEF_LIVE_SERVER_AT_DESIGN_TIME are used by properties  
  20. // which return objects that may need to be explicitly created via a function 
  21. // call prior to any access via the property. These items have been disabled  
  22. // in order to prevent accidental use from within the object inspector. You   
  23. // may enable them by defining LIVE_SERVER_AT_DESIGN_TIME or by selectively   
  24. // removing them from the $IFDEF blocks. However, such items must still be    
  25. // programmatically created via a method of the appropriate CoClass before    
  26. // they can be used.                                                          
  27. // ************************************************************************ //
  28. // Type Lib: C:\My Documents\DelphiMag, Oct99\ASP\SteveASO.tlb (1)
  29. // IID\LCID: {CB75DB3F-F931-4AB2-A10A-C9E45765E1E3}\0
  30. // Helpfile: 
  31. // DepndLst: 
  32. //   (1) v2.0 stdole, (C:\WINDOWS\SYSTEM\StdOle2.Tlb)
  33. //   (2) v4.0 StdVCL, (C:\WINDOWS\SYSTEM\STDVCL40.DLL)
  34. // ************************************************************************ //
  35. {$TYPEDADDRESS OFF} // Unit must be compiled without type-checked pointers. 
  36. interface
  37.  
  38. uses Windows, ActiveX, Classes, Graphics, OleServer, OleCtrls, StdVCL;
  39.  
  40. // *********************************************************************//
  41. // GUIDS declared in the TypeLibrary. Following prefixes are used:        
  42. //   Type Libraries     : LIBID_xxxx                                      
  43. //   CoClasses          : CLASS_xxxx                                      
  44. //   DISPInterfaces     : DIID_xxxx                                       
  45. //   Non-DISP interfaces: IID_xxxx                                        
  46. // *********************************************************************//
  47. const
  48.   // TypeLibrary Major and minor versions
  49.   SteveASOMajorVersion = 1;
  50.   SteveASOMinorVersion = 0;
  51.  
  52.   LIBID_SteveASO: TGUID = '{CB75DB3F-F931-4AB2-A10A-C9E45765E1E3}';
  53.  
  54.   IID_ISteveServerObj: TGUID = '{4C2D4D31-084E-4F38-ACA8-87DD5A2F2F6E}';
  55.   CLASS_SteveServerObj: TGUID = '{D1B27AC4-B8FF-4C71-B9BF-A1C01BFE199B}';
  56. type
  57.  
  58. // *********************************************************************//
  59. // Forward declaration of types defined in TypeLibrary                    
  60. // *********************************************************************//
  61.   ISteveServerObj = interface;
  62.   ISteveServerObjDisp = dispinterface;
  63.  
  64. // *********************************************************************//
  65. // Declaration of CoClasses defined in Type Library                       
  66. // (NOTE: Here we map each CoClass to its Default Interface)              
  67. // *********************************************************************//
  68.   SteveServerObj = ISteveServerObj;
  69.  
  70.  
  71. // *********************************************************************//
  72. // Interface: ISteveServerObj
  73. // Flags:     (4416) Dual OleAutomation Dispatchable
  74. // GUID:      {4C2D4D31-084E-4F38-ACA8-87DD5A2F2F6E}
  75. // *********************************************************************//
  76.   ISteveServerObj = interface(IDispatch)
  77.     ['{4C2D4D31-084E-4F38-ACA8-87DD5A2F2F6E}']
  78.     procedure DoIt; safecall;
  79.   end;
  80.  
  81. // *********************************************************************//
  82. // DispIntf:  ISteveServerObjDisp
  83. // Flags:     (4416) Dual OleAutomation Dispatchable
  84. // GUID:      {4C2D4D31-084E-4F38-ACA8-87DD5A2F2F6E}
  85. // *********************************************************************//
  86.   ISteveServerObjDisp = dispinterface
  87.     ['{4C2D4D31-084E-4F38-ACA8-87DD5A2F2F6E}']
  88.     procedure DoIt; dispid 1;
  89.   end;
  90.  
  91. // *********************************************************************//
  92. // The Class CoSteveServerObj provides a Create and CreateRemote method to          
  93. // create instances of the default interface ISteveServerObj exposed by              
  94. // the CoClass SteveServerObj. The functions are intended to be used by             
  95. // clients wishing to automate the CoClass objects exposed by the         
  96. // server of this typelibrary.                                            
  97. // *********************************************************************//
  98.   CoSteveServerObj = class
  99.     class function Create: ISteveServerObj;
  100.     class function CreateRemote(const MachineName: string): ISteveServerObj;
  101.   end;
  102.  
  103.  
  104. // *********************************************************************//
  105. // OLE Server Proxy class declaration
  106. // Server Object    : TSteveServerObj
  107. // Help String      : SteveServerObj Object
  108. // Default Interface: ISteveServerObj
  109. // Def. Intf. DISP? : No
  110. // Event   Interface: 
  111. // TypeFlags        : (2) CanCreate
  112. // *********************************************************************//
  113. {$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
  114.   TSteveServerObjProperties= class;
  115. {$ENDIF}
  116.   TSteveServerObj = class(TOleServer)
  117.   private
  118.     FIntf:        ISteveServerObj;
  119. {$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
  120.     FProps:       TSteveServerObjProperties;
  121.     function      GetServerProperties: TSteveServerObjProperties;
  122. {$ENDIF}
  123.     function      GetDefaultInterface: ISteveServerObj;
  124.   protected
  125.     procedure InitServerData; override;
  126.   public
  127.     constructor Create(AOwner: TComponent); override;
  128.     destructor  Destroy; override;
  129.     procedure Connect; override;
  130.     procedure ConnectTo(svrIntf: ISteveServerObj);
  131.     procedure Disconnect; override;
  132.     procedure DoIt;
  133.     property  DefaultInterface: ISteveServerObj read GetDefaultInterface;
  134.   published
  135. {$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
  136.     property Server: TSteveServerObjProperties read GetServerProperties;
  137. {$ENDIF}
  138.   end;
  139.  
  140. {$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
  141. // *********************************************************************//
  142. // OLE Server Properties Proxy Class
  143. // Server Object    : TSteveServerObj
  144. // (This object is used by the IDE's Property Inspector to allow editing
  145. //  of the properties of this server)
  146. // *********************************************************************//
  147.  TSteveServerObjProperties = class(TPersistent)
  148.   private
  149.     FServer:    TSteveServerObj;
  150.     function    GetDefaultInterface: ISteveServerObj;
  151.     constructor Create(AServer: TSteveServerObj);
  152.   protected
  153.   public
  154.     property DefaultInterface: ISteveServerObj read GetDefaultInterface;
  155.   published
  156.   end;
  157. {$ENDIF}
  158.  
  159.  
  160. procedure Register;
  161.  
  162. implementation
  163.  
  164. uses ComObj;
  165.  
  166. class function CoSteveServerObj.Create: ISteveServerObj;
  167. begin
  168.   Result := CreateComObject(CLASS_SteveServerObj) as ISteveServerObj;
  169. end;
  170.  
  171. class function CoSteveServerObj.CreateRemote(const MachineName: string): ISteveServerObj;
  172. begin
  173.   Result := CreateRemoteComObject(MachineName, CLASS_SteveServerObj) as ISteveServerObj;
  174. end;
  175.  
  176. procedure TSteveServerObj.InitServerData;
  177. const
  178.   CServerData: TServerData = (
  179.     ClassID:   '{D1B27AC4-B8FF-4C71-B9BF-A1C01BFE199B}';
  180.     IntfIID:   '{4C2D4D31-084E-4F38-ACA8-87DD5A2F2F6E}';
  181.     EventIID:  '';
  182.     LicenseKey: nil;
  183.     Version: 500);
  184. begin
  185.   ServerData := @CServerData;
  186. end;
  187.  
  188. procedure TSteveServerObj.Connect;
  189. var
  190.   punk: IUnknown;
  191. begin
  192.   if FIntf = nil then
  193.   begin
  194.     punk := GetServer;
  195.     Fintf:= punk as ISteveServerObj;
  196.   end;
  197. end;
  198.  
  199. procedure TSteveServerObj.ConnectTo(svrIntf: ISteveServerObj);
  200. begin
  201.   Disconnect;
  202.   FIntf := svrIntf;
  203. end;
  204.  
  205. procedure TSteveServerObj.DisConnect;
  206. begin
  207.   if Fintf <> nil then
  208.   begin
  209.     FIntf := nil;
  210.   end;
  211. end;
  212.  
  213. function TSteveServerObj.GetDefaultInterface: ISteveServerObj;
  214. begin
  215.   if FIntf = nil then
  216.     Connect;
  217.   Assert(FIntf <> nil, 'DefaultInterface is NULL. Component is not connected to Server. You must call ''Connect'' or ''ConnectTo'' before this operation');
  218.   Result := FIntf;
  219. end;
  220.  
  221. constructor TSteveServerObj.Create(AOwner: TComponent);
  222. begin
  223.   inherited Create(AOwner);
  224. {$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
  225.   FProps := TSteveServerObjProperties.Create(Self);
  226. {$ENDIF}
  227. end;
  228.  
  229. destructor TSteveServerObj.Destroy;
  230. begin
  231. {$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
  232.   FProps.Free;
  233. {$ENDIF}
  234.   inherited Destroy;
  235. end;
  236.  
  237. {$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
  238. function TSteveServerObj.GetServerProperties: TSteveServerObjProperties;
  239. begin
  240.   Result := FProps;
  241. end;
  242. {$ENDIF}
  243.  
  244. procedure TSteveServerObj.DoIt;
  245. begin
  246.   DefaultInterface.DoIt;
  247. end;
  248.  
  249. {$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
  250. constructor TSteveServerObjProperties.Create(AServer: TSteveServerObj);
  251. begin
  252.   inherited Create;
  253.   FServer := AServer;
  254. end;
  255.  
  256. function TSteveServerObjProperties.GetDefaultInterface: ISteveServerObj;
  257. begin
  258.   Result := FServer.DefaultInterface;
  259. end;
  260.  
  261. {$ENDIF}
  262.  
  263. procedure Register;
  264. begin
  265.   RegisterComponents('Servers',[TSteveServerObj]);
  266. end;
  267.  
  268. end.
  269.